package com.aliware.tianchi.utils;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author XDD
 * @project service
 * @date 2021/9/4
 * @description Good Good Study,Day Day Up.
 */
public class RandomUtils {
    private final static String MATHLIST = "123456789";

    public static Integer genInt(int length,String pre) {
        String result = pre+gen(MATHLIST,length);
        return Integer.parseInt(result.trim());
    }

    private static String gen(String mathlist, int length) {
        char[] charArray = mathlist.toCharArray();
        char[] newCharArray = new char[charArray.length];
        ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
        for (int i=0;i<length;i++){
            int anInt = threadLocalRandom.nextInt(charArray.length);
            newCharArray[i] = charArray[anInt];
        }
        return new String(newCharArray);
    }

//    public static void main(String[] args) {
//        for (int i=0;i<=100;i++){
//            genInt(5);
//        }
//    }
}
